﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Data.Initializers
{
    class ConnectDB
    {
        //private const string dbCart = @"Server=TUNG-PC\SQLEXPRESS; Database=dbCart; User ID=sa; password=123456";//

        private const string dbCart = @"Server=172.16.40.146\SQLEXPRESS,1433; Database=dbCart; User ID=sa; password=Tung123";


        public static SqlConnection GetSQlConnection(SqlConnection connect)
        {
            try
            {
                connect.ConnectionString = dbCart;
                connect.Open();
                return connect;
            }
            catch (Exception)
            {
                return null;
            }
        }

        public static void CloseConnection(SqlConnection connect)
        {
            if (connect == null) return;
            if (connect.State == ConnectionState.Open)
            {
                connect.Close();
            }
            connect.Dispose();
        } 
    }
}
